
<?php

/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2016/11/23
 * Time: 17:06
 */

require("./Include/conn.php");

function singlepic($pic_id){
    global $link;
    if($pic_id == null){
        return;
    }
    else{
        $sql = "SELECT `pic_praisecnt` FROM `pw_pic` WHERE `pic_id`=$pic_id;";
        $result = mysqli_query($link,$sql);
        $row = mysqli_fetch_row($result);
        $praisecnt = $row[0];

        $sql = "SELECT `pic_favcnt` FROM `pw_pic` WHERE `pic_id`=$pic_id;";
        $result = mysqli_query($link,$sql);
        $row = mysqli_fetch_row($result);
        $favcnt = $row[0];

        $sql = "SELECT `pic_name` FROM `pw_pic` WHERE `pic_id`=$pic_id;";
        $result = mysqli_query($link,$sql);
        $row = mysqli_fetch_row($result);
        $pic_name = $row[0];

        $sql = "SELECT `pic_instr` FROM `pw_pic` WHERE `pic_id`=$pic_id;";
        $result = mysqli_query($link,$sql);
        $row = mysqli_fetch_row($result);
        $pic_instr = $row[0];
        echo "<div class=\"col-sm-6 col-md-3\">
					<div class=\"thumbnail\">
			            <a href=\""."picshow.php?picid=".$pic_id."\">
						<img src=\"img\upload/".$pic_id.".jpg\"
							 alt=\"通用的占位符缩略图\"> 
					    </a>
						<div class=\"caption\">
							<h3>$pic_name</h3>
							<p>$pic_instr</p>
							<p>
								<a href=\"praise.php?pic_id=$pic_id\" class=\"btn btn-primary\" role=\"button\">
									点赞  $praisecnt
								</a>
								<a href=\"favor.php?pic_id=$pic_id\" class=\"btn btn-default\" role=\"button\">
									收藏  $favcnt
								</a>
							</p>
						</div>
						<form action='comment.php' method='post'>
				            <fieldset>
				            <input name=\"picid\" type=\"hidden\" value = $pic_id>
					            <label>评论</label><textarea type=\"text\" name='comment' style=\"width:250px;height:60px;\"></textarea> <button type=\"submit\" class=\"btn\">提交</button>
				            </fieldset>
			            </form>
					</div>
				</div>";
    }

}
function rowpic($id1,$id2,$id3,$id4){
    echo "<div class=\"row\">";
    singlepic($id1);
    singlepic($id2);
    singlepic($id3);
    singlepic($id4);
    echo "</div>";
}






function singlepic_user($pic_id){
    global $link;
    if($pic_id == null){
        return;
    }
    else{
        $sql = "SELECT `pic_praisecnt` FROM `pw_pic` WHERE `pic_id`=$pic_id;";
        $result = mysqli_query($link,$sql);
        $row = mysqli_fetch_row($result);
        $praisecnt = $row[0];

        echo "<div class=\"col-sm-6 col-md-3\">
					<div class=\"thumbnail\">
			            <a href=\""."picshow.php?picid=".$pic_id."\">
						<img src=\"img\upload/".$pic_id.".jpg\"
							 alt=\"通用的占位符缩略图\"> 
					    </a>
						<div class=\"caption\">
							<h3>图片名称</h3>
							<p>图片说明</p>
							<p>
								<a href=\"praise.php?pic_id=$pic_id\" class=\"btn btn-primary\" role=\"button\">
									点赞  $praisecnt
								</a>
								<a href=\"delete.php?pic_id=$pic_id\" class=\"btn btn-default\" role=\"button\">
									删除
								</a>
							</p>
						</div>
					</div>
				</div>";
    }

}
function rowpic_user($id1,$id2,$id3,$id4){
    echo "<div class=\"row\">";
    singlepic_user($id1);
    singlepic_user($id2);
    singlepic_user($id3);
    singlepic_user($id4);
    echo "</div>";
}



